package com.foreknow.demo13;

import java.util.*;

public class ListMapDemo {
    public static void main(String[] args) {
        Person p1 = new Person();
        p1.setName("fender");
        Person p2 = new Person();
        p2.setName("gibson");
        Map<Integer,Person> map1 = new HashMap();
        map1.put(1,p1);
        map1.put(2,p2);
        Person p3 = new Person();
        p3.setName("tom");
        Person p4 = new Person();
        p4.setName("lily");
        Map<Integer,Person> map2 = new HashMap();
        map2.put(3,p3);
        map2.put(4,p4);
        Person p5 = new Person();
        p5.setName("小亮");
        Person p6 = new Person();
        p6.setName("小红");
        Map<Integer,Person> map3 = new HashMap();
        map3.put(5,p5);
        map3.put(6,p6);

        List<Map<Integer,Person>> list = new ArrayList<>();
        list.add(map1);
        list.add(map2);
        list.add(map3);

        Iterator<Map<Integer, Person>> it = list.iterator();
        while (it.hasNext()) {
            Map map = it.next();
            Set<Map.Entry<Integer,Person>> set = map.entrySet();
            Iterator<Map.Entry<Integer,Person>> itm = set.iterator();
            while (itm.hasNext()) {
                Map.Entry entry = itm.next();
                Integer key = (Integer) entry.getKey();
                Person p = (Person) entry.getValue();
                System.out.println(key + "----" + p.getName());
            }
        }
    }
}
